package com.ruoyi.project.info.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.info.domain.AppInfo;
import com.ruoyi.project.info.service.IAppInfoService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 程序配置Controller
 * 
 * @author wyh
 * @date 2024-07-04
 */
@RestController
@RequestMapping("/info/info")
public class AppInfoController extends BaseController
{
    @Autowired
    private IAppInfoService appInfoService;

    /**
     * 查询程序配置列表
     */
    @PreAuthorize("@ss.hasPermi('info:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppInfo appInfo)
    {
        startPage();
        List<AppInfo> list = appInfoService.selectAppInfoList(appInfo);
        return getDataTable(list);
    }

    /**
     * 导出程序配置列表
     */
    @PreAuthorize("@ss.hasPermi('info:info:export')")
    @Log(title = "程序配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppInfo appInfo)
    {
        List<AppInfo> list = appInfoService.selectAppInfoList(appInfo);
        ExcelUtil<AppInfo> util = new ExcelUtil<AppInfo>(AppInfo.class);
        util.exportExcel(response, list, "程序配置数据");
    }

    /**
     * 获取程序配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('info:info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(appInfoService.selectAppInfoById(id));
    }

    /**
     * 新增程序配置
     */
    @PreAuthorize("@ss.hasPermi('info:info:add')")
    @Log(title = "程序配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppInfo appInfo)
    {
        return toAjax(appInfoService.insertAppInfo(appInfo));
    }

    /**
     * 修改程序配置
     */
    @PreAuthorize("@ss.hasPermi('info:info:edit')")
    @Log(title = "程序配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppInfo appInfo)
    {
        return toAjax(appInfoService.updateAppInfo(appInfo));
    }

    /**
     * 删除程序配置
     */
    @PreAuthorize("@ss.hasPermi('info:info:remove')")
    @Log(title = "程序配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appInfoService.deleteAppInfoByIds(ids));
    }
}
